/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gra.Input;

import gra.Gra;
import gra.Renderer.Renderer;
import gra.mechanika.Mechanika;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

/**
 *
 * @author Grog
 */
public class Input {

    public Mechanika mechanika;
    public Renderer renderer;

    public Input(Renderer renderer, Mechanika mechanika) {
        this.renderer = renderer;
        this.mechanika = mechanika;


    }

    public void przechwycZdarzenie() {
        //Zdarzenia wymagające czasowego wstrzymania czasu      
        if (mechanika.timer.getTime() > 0.2f) {
            if (Keyboard.isKeyDown(Keyboard.KEY_1)) {
                mechanika.stworzObiekt("x");
                System.out.println("stworzony");
            }
            if (Mouse.isButtonDown(2)) {
                if (Mouse.isGrabbed()) {
                    Mouse.setGrabbed(false);
                } else {
                    Mouse.setGrabbed(true);
                }
                System.out.println(Mouse.isGrabbed());

            }




            if (Keyboard.isKeyDown(Keyboard.KEY_ESCAPE)) {
                Gra.posprzataj();
            }

            if (Keyboard.isKeyDown(Keyboard.KEY_F2)) {
                
                
                if (Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) {
                    renderer.wlaczTekstury(false);
                    return;
                }
                renderer.wlaczTekstury(true);
                
            }




            if (Keyboard.isKeyDown(Keyboard.KEY_F11)) {
                //renderer.fullscreen();
                mechanika.getObiekt(0).setSpeed(0);
                System.out.println("dlugosc " + mechanika.getObiekt(0).getDlugosc());
            }

            if (Keyboard.isKeyDown(Keyboard.KEY_F10)) {
                mechanika.getObiekt(0).skaluj_Obj(2);
                System.out.println("skaluje ");
            }

            if (Keyboard.isKeyDown(Keyboard.KEY_F12)) {

                renderer.resetujKamere();
                System.out.println("reset kamery ");
            }

            mechanika.timer.stoperReset();
        }


        if (Mouse.isGrabbed()) {

            if ((Keyboard.isKeyDown(Keyboard.KEY_MINUS)) || (Keyboard.isKeyDown(Keyboard.KEY_NUMPADEQUALS))) {
                renderer.zmianaSzybkosciKam(-1f);
                System.out.println();

            }
            if ((Keyboard.isKeyDown(Keyboard.KEY_EQUALS)) || (Keyboard.isKeyDown(Keyboard.KEY_ADD))) {
                renderer.zmianaSzybkosciKam(1f);

            }
        }
    }
}
